import 'package:vista/shared/models/base_frame.dart';

/// 主题挑战画面
/// 存储主题挑战信息，如摄影中的主题设定般组织挑战活动
class ThemeChallenge extends BaseFrame {
  final String id; // 主题ID
  final String title; // 主题标题
  final String description; // 主题描述
  final String coverImage; // 封面图片
  final DateTime createdAt; // 创建时间

  const ThemeChallenge({
    required this.id,
    required this.title,
    required this.description,
    required this.coverImage,
    required this.createdAt,
  });

  /// 从JSON创建主题挑战画面
  factory ThemeChallenge.fromJson(Map<String, dynamic> json) {
    return ThemeChallenge(
      id: json['id'] as String,
      title: json['title'] as String,
      description: json['description'] as String,
      coverImage: json['coverImage'] as String,
      createdAt: DateTime.parse(json['createdAt'] as String),
    );
  }

  @override
  List<Object?> get props => [id, title, description, coverImage, createdAt];

  @override
  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'title': title,
      'description': description,
      'coverImage': coverImage,
      'createdAt': createdAt.toIso8601String(),
    };
  }
}
